package com.zd.kids.ui.adapter;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zd.kids.DataBean.UseGuideDataBean;
import com.zd.kids.R;
import com.zd.kids.ui.activity.VideoRecordActivity;

import java.util.List;

import androidx.annotation.Nullable;

/**
 * @ClassName: com.zd.kids.ui.adapter
 * @Description:
 * @Author: hyy
 * @Date: 2020/9/3
 * @Time: 6:54 PM
 */
public class UseGuideAdapter extends BaseQuickAdapter<UseGuideDataBean.ListBean, BaseViewHolder> {

    String groupPosition;

    public UseGuideAdapter(@Nullable List<UseGuideDataBean.ListBean> data, String groupPosition) {
        super(R.layout.activity_use_guide_item, data);
        this.groupPosition = groupPosition;
    }

    @Override
    protected void convert(BaseViewHolder helper, UseGuideDataBean.ListBean item) {

        TextView tv_name = helper.getView(R.id.tv_name);
        tv_name.setText(item.getTitle());

        TextView tv_positon = helper.getView(R.id.tv_positon);
        tv_positon.setText((helper.getAbsoluteAdapterPosition() + 1) + "");

        if ("0".equals(groupPosition)) {
            tv_positon.setTextColor(0xff1b83c6);
        } else if ("1".equals(groupPosition)) {
            tv_positon.setTextColor(0xffE89100);
        } else if ("2".equals(groupPosition)) {
            tv_positon.setTextColor(0xff009300);
        }
        LinearLayout llRoot = helper.getView(R.id.ll_rootview);
        llRoot.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!TextUtils.isEmpty(item.getVideo_path())) {
                    Intent intent = new Intent(mContext, VideoRecordActivity.class);
                    intent.putExtra("VIDEO_PATH", item.getVideo_path());
                    mContext.startActivity(intent);
                }
            }
        });
    }
}
